import { useState } from "react"
import { Radio } from 'antd';

const FromInput=(props)=>{
    const[state,setState]=useState({
        date:'',
        title:'',
        priority:'1'
    })
    // 日期
    const updateDate = (e) => {
        // console.log(e)
        setState({
            ...state, date: e.target.value
    
        })
    }
    // 标题
    const updateTitle = (e) => {
        // console.log(e)
        setState({
            ...state, title: e.target.value
        })
    }
    // 优先级
    const changePriority=(e)=>{
        setState({
            ...state,priority:e.target.value
        })
    }
    const save = () => {
        // console.log(state)
        let { title, priority, date } = state
       props.tolist({ title, priority, date })
    }
    return (<>
     日期：<input type="text" value={state.date} onChange={updateDate} /><br />
            标题：<input type="text" value={state.title} onChange={updateTitle} /><br />
            优先级：<Radio.Group value={state.priority} onChange={changePriority}>
                <Radio value='1' checked={state.priority === '1'}>A</Radio>
                <Radio value='2' checked={state.priority === '2'}>B</Radio>
                <Radio value='3' checked={state.priority === '3'}>C</Radio>
                <Radio value='4' checked={state.priority === '4'}>D</Radio>
            </Radio.Group>
            <button onClick={save}>添加</button>
    </>)
}
export default FromInput